import { useOnAddStore } from '@/stores/onAdd'
import { useRouter } from 'vue-router'
import { ref } from 'vue'
import { usePayOderStore } from '@/stores/payOder'

export const useOnAdd = () => {
    const onAddStore = useOnAddStore()
    const router = useRouter()
    const username = ref('')
    const tel = ref('')
    const address = ref('')
    const usePayOder = usePayOderStore()

    const getCheckGoodsListId = () => {
        const productIds = usePayOder.checkGoodsList.map(item => item.id)
        let b = productIds.toString()
       
        onAddStore.saveOrderid(b)
        return productIds
    }
    const onSubmit = () => {
        console.log('哈哈啊')

        const infor = {
            username: username.value,
            tel: tel.value,
            address: address.value,
        }
        router.push({ path: '/payOder', query: infor })
        onAddStore.saveAddRess(infor)

        getCheckGoodsListId()
    }
    return { username, tel, address, onSubmit }
}
